package com.yunfeisoft.business.model;

import com.yunfeisoft.base.model.WorkflowInstance;
import com.yunfeisoft.common.base.BaseModel;
import com.yunfeisoft.common.sql.record.TransientField;
import com.yunfeisoft.common.utils.DateUtils;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * ClassName: VacationApproval
 * Description: 员工休假审批表
 *
 * @Author: Jackie liu
 * Date: 2020-05-14
 */
@Entity
@Table(name = "TT_VACATION_APPROVAL")
public class VacationApproval extends BaseModel implements Serializable {

    /**
     * Field serialVersionUID: 序列号
     */
    private static final long serialVersionUID = 1L;

    /**
     * 流程定义id
     */
    @Column
    private String workflowDefineId;

    /**
     * 部门
     */
    @Column
    private String deptName;

    /**
     * 职务
     */
    @Column
    private String position;

    /**
     * 休假类别(1病假、2事假、3婚假、4年假、5其他)
     */
    @Column
    private Integer type;

    /**
     * 其他假期
     */
    @Column
    private String other;

    /**
     * 开始时间
     */
    @Column
    private Date beginDate;

    /**
     * 结束时间
     */
    @Column
    private Date endDate;

    /**
     * 备注
     */
    @Column
    private String remark;

    @TransientField
    private Integer validStatus;
    @TransientField
    private String createName;
    //下一节点处理人
    private String nextStepUserId;

    public String getBeginDateStr() {
        if (beginDate != null) {
            return DateUtils.dateToString(beginDate);
        }
        return null;
    }

    public String getEndDateStr() {
        if (endDate != null) {
            return DateUtils.dateToString(endDate);
        }
        return null;
    }

    public String getValidStatusStr() {
        return WorkflowInstance.WorkflowInstanceStatusEnum.valueOf(validStatus);
    }

    public String getTypeStr() {
        return VacationTypeEnum.valueOf(type);
    }

    public String getWorkflowDefineId() {
        return workflowDefineId;
    }

    public void setWorkflowDefineId(String workflowDefineId) {
        this.workflowDefineId = workflowDefineId;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getOther() {
        return other;
    }

    public void setOther(String other) {
        this.other = other;
    }

    public Date getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getValidStatus() {
        return validStatus;
    }

    public void setValidStatus(Integer validStatus) {
        this.validStatus = validStatus;
    }

    public String getCreateName() {
        return createName;
    }

    public void setCreateName(String createName) {
        this.createName = createName;
    }

    public String getNextStepUserId() {
        return nextStepUserId;
    }

    public void setNextStepUserId(String nextStepUserId) {
        this.nextStepUserId = nextStepUserId;
    }

    /**
     * 休假类别(1病假、2事假、3婚假、4年假、5其他)
     */
    public enum VacationTypeEnum {

        SICK_LEAVE(1, "病假"),
        COMPASSIONATE_LEAVE(2, "事假"),
        MARRIAGE_HOLIDAY(3, "婚假"),
        ANNUAL_LEAVE(4, "年假"),
        OTHER(5, "其他");

        private int value;
        private String label;

        private VacationTypeEnum(int value, String label) {
            this.value = value;
            this.label = label;
        }

        public static String valueOf(Integer value) {
            if (value == null) {
                return null;
            }
            for (VacationTypeEnum loop : VacationTypeEnum.values()) {
                if (value == loop.getValue()) {
                    return loop.getLabel();
                }
            }
            return null;
        }

        public int getValue() {
            return value;
        }

        public String getLabel() {
            return label;
        }
    }

}